#ifndef _BARTER_SERVER_LOGINMODULE_H_
#define _BARTER_SERVER_LOGINMODULE_H_

#include "DBManager.h"
#include "IBackEndModule.h"

#define LoginModule_ID 0x11

enum LoginModule_Events
{
	LoginModule_NewSession   = 0x0001,
	LoginModule_AuthDetails  = 0x0002,
	LoginModule_CloseSession = 0x0004,
	LoginModule_GetClearance = 0x0008,
};

enum LoginModule_Status
{
	LoginModule_Connected     = 0x0001,
	LoginModule_Authenticated = 0x0003,
	LoginModule_NotConnected  = 0x0004,
};

class LoginModule
{
private:
	Handle<DBInstance> DBHandle;
	Connection* Conn;
	std::string UserName, AuthDetails;
	int Clearance;
	int Status;
	NetworkMessage NewSession(NetworkMessage*);
	NetworkMessage AuthDetails(NetworkMessage*);
	NetworkMessage CloseSession(NetworkMessage*);
public:
	LoginModule();
	int GetModuleID() const
	{
		return LoginModule_ID;
	}
	void SetConnection(Connection* c)
	{
		Conn = c;
	}
	NetworkMessage OnEvent(unsigned long, NetworkMessage*);
};

#endif // _BARTER_SERVER_LOGINMODULE_H_
